using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace MvcApplication4.Models.Mapping
{
    public class LOTEMap : EntityTypeConfiguration<LOTE>
    {
        public LOTEMap()
        {
            // Primary Key
            this.HasKey(t => t.ID_Lote);

            // Properties
            this.Property(t => t.ID_Lote)
                .IsRequired()
                .HasMaxLength(30);

            // Table & Column Mappings
            this.ToTable("LOTE");
            this.Property(t => t.ID_Lote).HasColumnName("ID_Lote");
            this.Property(t => t.ID_Vacina).HasColumnName("ID_Vacina");
            this.Property(t => t.ID_Laboratorio).HasColumnName("ID_Laboratorio");
            this.Property(t => t.Validade).HasColumnName("Validade");
            this.Property(t => t.Num_Doses).HasColumnName("Num_Doses");

            // Relationships
            this.HasRequired(t => t.tb_Laboratorio)
                .WithMany(t => t.LOTEs)
                .HasForeignKey(d => d.ID_Laboratorio);
            this.HasRequired(t => t.tb_Vacina)
                .WithMany(t => t.LOTEs)
                .HasForeignKey(d => d.ID_Vacina);

        }
    }
}
